package edu.scu.declaresys.web.action;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ModelDriven;

import edu.scu.declaresys.config.IAttrName;
import edu.scu.declaresys.service.ServiceFactory;
import edu.scu.declaresys.service.intr.IProjectService;
import edu.scu.declaresys.util.PageList;
import edu.scu.declaresys.vo.Project;
import edu.scu.declaresys.web.ABaseAction;

public class SearchProjectAction extends ABaseAction implements ModelDriven<Project>
{
	private static final long	serialVersionUID	= 4666747079525834524L;

	private IProjectService projectService = ServiceFactory.createProjectService();
	
	private Project project = new Project();
	
	private Integer page;
	
	//
	//
	//
	public String searchShowSearchOption() throws Exception
	{
		request.setAttribute(IAttrName.CLASS_LIST, ServiceFactory.createProjectClassService().findClassList());
		return Action.SUCCESS;
	}
	
	public String searchProject() throws Exception
	{
		if(page == null)
		{
			page = 1;
		}
		PageList<Project> voLst = projectService.searchProject(project, page);
		request.setAttribute(IAttrName.PROJECT_LIST, voLst);
		request.setAttribute(IAttrName.PROJECT_LIST_SIZE, voLst.size());
		return Action.SUCCESS;
	}
	
	//
	// Setters and Getters.
	//
	@Override
	public Project getModel()
	{
		return project;
	}

	public Integer getPage()
	{
		return page;
	}

	public void setPage(Integer page)
	{
		this.page = page;
	}
	
	
}
